home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / HyperCard Goodies / AppleTalk Stuff / HyperAppleTalk / MISC / atalkXCMD.h < prev    next >
Text File  |  1988-04-25  |  7KB  |  159 lines

  1. /*******************************************************************\
  2. * file:     atalkxcmd.h                                                *
  3. * version:    1.06ß                                                    *
  4. *                                                                    *
  5. * Header file for the AppleTalk/Hypercard interface.   Defines some    *
  6. * lowmem globals (PortBUse and SPCongfig) and other resource stuff.    *                                                *
  7. * -----------------------------------------------------------------    *
  8. * By:    Donald Koscheka                                                *
  9. * Date:    21-Sept-87                                                    *
  10. * ©    Copyright 1987, Apple Computer, Inc.                            *
  11. *    All Rights Reserved                                                *
  12. * -----------------------------------------------------------------    *
  13. *                        Modification History                        *
  14. * -----------------------------------------------------------------    *
  15. *  Date           | By    |                     Description                    *
  16. * -----------------------------------------------------------------    *
  17. * 21-Sep-87    | DK    | file created                                    *
  18. * 31-Sep-87 | DK    | modified Masterblock for preferred calls        *
  19. *  1-Dec-87    | DK    | modified Client waiting queue to FIFO struct    *
  20. *  2-Dec-87    | DK    | added 4K response structures to server and    *
  21. *            |        | client transaction blocks.                    *
  22. *  7-Dec-87    | DK    | converted NBP to Parm block implemention        *
  23. *  8-Dec-87 | DK    | "escalation" flag for server isInUse field    *
  24. * 11-Dec-87    | DK    | converted nonrel objects in MasterBlock to     *
  25. *            | DK    | pointers from locked handles.    Client Response    *
  26. *            |        | buffer converted to array from handle            *
  27. * 10-Feb-88    | DK    | Added a flag that is set from ATPReceive to     *
  28. *            |         | tell atpclose to hold off (in case it is         *
  29. *            |        | called as part of a callback) & which ATPclose*
  30. *            |         | sets to tell atpreceive to close down.        *
  31. * -----------------------------------------------------------------    *
  32. \*******************************************************************/
  33.  
  34. #include    <AppleTalk.h>
  35.  
  36. #define        PortBUse    0x291
  37. #define        SPConfig    0x1FB
  38. #define        ASYNC        1
  39. #define        SYNC        0
  40. #define        NODE_NAME    -16096        /* string resource with node name from Chooser    */
  41. #define        MAXNODES    100            /* maximum # of nodes  for this zone            */
  42. #define        NBPLSIZE    120            /* size of a local buffer for NBP                */
  43. #define        NN            30            /* number of names in the lookup table            */
  44. #define        CQSIZE        4            /* number of client transaction blocks            */
  45. #define        SQSIZE        8            /* number of server transaction blocks            */
  46. #define        ENTITYSIZE    110            /* size of an entity in the lookup buffer        */
  47. #define        ATPBSIZE    578            /* size of an atp record buffer                    */
  48. #define        MAXBDS        8            /* maximum # of elements in a BDS Structure        */
  49. #define        AUTOSIZE    5            /* size of the autoresponse data                */
  50.  
  51. #define        CLIENT        1            /* node to be connected as a client only        */
  52. #define        SERVER        2            /* node to be connected as a server only        */
  53.  
  54. #define        CLOSE_OK    0            /* not a "CLOSE" critical routine                */
  55. #define        RECEIVING    1            /* currently executing ATPReceive                */
  56. #define        CLOSE_NOW    2            /* tells atpReceive to close down when done        */
  57.  
  58. /*** Server isInUse escalation strategy     ***/
  59. #define        IDLE            0
  60. #define        WAIT_REQUEST    1
  61. #define        WAIT_RESPONSE    2
  62.  
  63. #define        empty            0L        /* empty is an alias for  NIL in hypercard         */
  64.  
  65.  
  66. #define        GlobalRspData    3728
  67. #define        GlobalRcvData    3279
  68.  
  69.  
  70. typedef    unsigned char    Byte;
  71.  
  72.     /***              ----- Client Side Waiting Queue Element    -----                   ***/
  73.     /***              Note the use of a singly linked-list - A FIFO doesn't          ***/
  74.     /***            need a back link (always add to the end, take away from          ***/
  75.     /***            the beginning).                                                  ***/
  76.  
  77. typedef    struct{                                    /* list element for client queue     */
  78.         struct ClientQRec     **next;                /* handle of the next element        */
  79.         char                **buf;                /* index to data buffer                */
  80.         long                size;                /* index to bds array                */
  81.         Handle                rsp;                /* handle to the response message    */
  82.         AddrBlock            addr;
  83.         short                count;
  84.         short                interval;
  85.     }ClientQRec, *ClientQPtr, **ClientQH;
  86.         
  87.     
  88.     /***                  ----- Server Side Transaction Block    -----                  ***/
  89. typedef    struct{
  90.         short            isInUse;
  91.         ATPParamBlock    pb;                        /* PB for getrequest/send response    */
  92.         BDSType            rspBDS;                    /* response buffer    data structure    */
  93.         char            buf[ATPBSIZE];            /* buffer for client request data    */
  94.         char            rspBuf[ATPBSIZE*MAXBDS];/* response data buffer                */
  95.     }ServerBlock, *ServerPtr;
  96.  
  97.  
  98.     /***                  ----- Client Side Transaction Block    -----                  ***/
  99. typedef    struct{
  100.         short            isInUse;
  101.         ATPParamBlock    pb;                        /* PB for PSendRequest                */
  102.         BDSType            bds;                    /* response buffer data structure    */
  103.         char            buf[ATPBSIZE];            /* data sent in this request        */
  104.         char            rsp[ATPBSIZE*MAXBDS];    /* response to this request            */
  105.         Handle            rspM;                    /* handle to the response message    */
  106.     }ClientBlock, *ClientPtr;
  107.     
  108.     
  109.     /***                  ----- A Hopefully Enlightening Note    -----                  ***/
  110.     /***                                                                          ***/
  111.     /***    You're probably wondering why we have two types of client structure      ***/
  112.     /***    (1) ClientQRec and (2) ClientBlock.  Well, the reason is that          ***/
  113.     /***    we can have only a finite number of requests "hopping" at a time       ***/
  114.     /***    (because we can only have a finite number of sockets open at a time). ***/
  115.     /***    The Client Blocks are the actual structures used in the transaction      ***/
  116.     /***    and are referred to as TRANSACTION BLOCKS throughout the code.          ***/
  117.     /***                                                                          ***/
  118.     /***    Because we cannot have more than about 10 such transactions active      ***/
  119.     /***     at a time, we need to keep track of which requests are assigned          ***/
  120.     /***    a transaction block and which requests are waiting for a block          ***/
  121.     /***    (because we allow the user to issue more requests than we can have      ***/
  122.     /***     sockets open.  If a transaction block is available, the request is       ***/
  123.     /***     said to be "active" (that is, queued up by AppleTalk),  If we have      ***/
  124.     /***     to pend the request, we keep it in our waiting queue.                  ***/
  125.  
  126.  
  127. typedef    struct {                                /* ATP protocol data                */
  128.         ServerPtr        Server;                    /* array/server transaction blocks    */
  129.         ClientPtr        Client;                    /* array/client transaction blocks    */
  130.         ClientQH        FirstRequest;            /* SendRequest wait "q"(client use)    */
  131.         ClientQH        LastRequest;            /* Last element in the waiting "q"    */        
  132.         short            checkPoint;                /* whehter in ATPReceive or ATPClose*/
  133.         AddrBlock        ServerAddr;                /* address of the server socket        */
  134.         char            autoRsp[256];            /* the autorespond message            */
  135. }ATPBlock;
  136.  
  137. typedef    struct{                                    /* Name Binding Protocol Structures    */
  138.         short            Registered;                /* true if we are already registered*/
  139.         short            EntCount;                /* number of entities visible        */
  140.         Handle            LookUpBuffer;            /* handle to the lookup buffer        */
  141.         NamesTableEntry    NTEntry;                /* entry into the names table        */
  142.         ZonesTable        ;                        /* table of visible zones            */
  143.         char            NBPLocal[NBPLSIZE];        /* used internally by NBP            */
  144. }NBPBlock;
  145.         
  146.  
  147. ATPBlock    *ATPInit();
  148. short        ATPKill();
  149. short         Request();
  150. short        PollRequests();
  151. short        Respond();
  152.  
  153. NBPBlock    *NBPInit();
  154. short        NBPKill();
  155. short        ConfirmName();
  156. short         ExtractName();
  157. short        Lookup();
  158. short        NodeRegister();
  159.